import {ByteRange_Pro} from "@/utils/utils"

export const addSchema: FormSchema = {
    "style": {
        "width": "auto"
    },
    "formItemLayout": {
        "labelCol": {
            "span": 6
        },
        "wrapperCol": {
            "span": 18
        }
    },
    "formItem": [
        {
            "type": "input",
            "label": "策略名称",
            "key": "name",
            "value": "",
            "props": {
                "placeholder": "策略名称"
            },
            "rules": [
                {
                    "required": true,
                    "message": "策略名称不能为空"
                },
                {
                    "validator":(rule,value,callback)=>{return ByteRange_Pro(rule,value,callback,32)},
                    "message": "策略名称最多32个字节"
                }
            ]
        },
        {
            "type": "input",
            "label": "进程名",
            "key": "processname",
            "value": "",
            "props": {
                "placeholder": "进程名(*代表全部)"
            },
            "rules": [
                {
                    "required": true,
                    "message": "进程名不能为空"
                }
            ]
        },
        {
            "type": "select",
            "label": "协议",
            "key": "protocol",
            "value": 0,
            "options": [
                {
                    "value": 0,
                    "label": "TCP"
                },
                {
                    "value": 1,
                    "label": "UDP"
                },
                {
                    "value": 2,
                    "label": "TCP,UDP"
                }
            ]
        },
        {
            "type": "inputNumber",
            "label": "本地端口",
            "key": "port",
            "value": 0,
            "props": {
                "min": 0,
                "max": 65535,
                "placeholder": "端口号范围为0-65535"
            },
            "rules": [
                {
                    "required": true,
                    "message": "端口号不能为空"
                },
                {
                    "type": 'number',
                    "min": 0,
                    "max": 65535,
                    "message": "端口号范围为0-65535"
                }
            ]
        },
        {
            "type": "radio",
            "label": "是否启用",
            "key": "using",
            "value": 0,
            "options": [
                {
                    "value": 1,
                    "label": "是"
                },
                {
                    "value": 0,
                    "label": "否"
                }
            ]
        },
    ]
}
